#!/usr/bin/python
#2013 summer iul
from Tkinter import*
root = Tk()
can = Canvas(root,width = 740,height = 780)
can.pack()
def stan():
	il = 0
	l1 = scl
	while il < 5:
		can.create_line(0,scl*10+l1,740,scl*10+l1)
		l1 = l1 + scl
		il = il + 1
ff = open('in','r')
scl = 10
down = True
down1 = True
char = "C"
i = 0
pos_x = []
pos_x = range(20,720,scl*2)
while True:
	ch = ff.read(1)
	if not ch:
		break
	elif ch == 'C':
		print "C"
		y = scl*15.5
		x = pos_x[i]
		can.create_line(x-scl/2,y+scl/2,x+scl*1.5,y+scl/2)
		i = i + 1
		char1 = char
		char = "C"
		down = False
	elif ch == 'D':
		print "D"
		y = scl*15
		x = pos_x[i]
		i = i + 1
		char1 = char
		char = "D"
	elif ch == 'E':
		print "E"
		y = scl*14.5
		x = pos_x[i]
		i = i + 1
		char1 = char
		char = "E"
		down = False
	elif ch == 'F':
		print "F"
		y = scl*14
		x = pos_x[i]
		i = i + 1
		char1 = char
		char = "F"
		down = False
	elif ch == 'G':
		print "F"
		y = scl*13.5
		x = pos_x[i]
		i = i + 1
		char1 = char
		char = "G"
		down = False
	elif ch == 'A':
		print "A"
		y = scl*13
		x = pos_x[i]
		i = i + 1
		char = "A"
		down = False
	elif ch == 'B':
		print "B"
		y = scl*12.5
		x = pos_x[i]
		i = i + 1
		char1 = char
		char = "B"
		down = False
	elif ch == 'c':
		print "c"
		y = scl*12
		x = pos_x[i]
		i = i + 1
		char = "c"
		down = True
	elif ch == 'd':
		print "d"
		y = scl*11.5
		x = pos_x[i]
		i = i + 1
		char = "d"
		down1 = down
		down = True
	elif ch == 'e':
		print "e"
		y = scl*11
		x = pos_x[i]
		i = i + 1
		char1 = char
		char = "e"
		down = True
	elif ch == 'f':
		print "f"
		y = scl*10.5
		x = pos_x[i]
		i = i + 1
		char1 = char
		down = True
	elif ch == '(':
		print "("
		y2 = y
		x2 = x
		if down == False:
			can.create_oval(x,y,x+scl,y+scl,fill = 'black')
			can.create_line(x+scl,y+scl/2,x+scl,y-scl*3)
		else:
			can.create_oval(x,y,x+scl,y+scl,fill = 'black')
			can.create_line(x,y+scl/2,x,y+scl*4)
	elif ch == ')':
		print ")"
		if down1 == False or down == False:
			can.create_oval(x,y,x+scl,y+scl,fill = 'black')
			can.create_line(x+scl,y+scl/2,x+scl,y-scl*3)
			can.create_line(x2+scl,y2-scl*3,x+scl,y-scl*3,width = 2)
		else:
			can.create_oval(x,y,x+scl,y+scl,fill = 'black')
			can.create_line(x,y+scl/2,x,y+scl*4)
			can.create_line(x2,y2+scl*4,x,y+scl*4,width = 2)
	elif ch == '{':
		print "{"
		y2 = y
		x2 = x
		if down == False:
			can.create_oval(x,y,x+scl,y+scl,fill = 'black')
			can.create_line(x+scl,y+scl/2,x+scl,y-scl*3)
		else:
			can.create_oval(x,y,x+scl,y+scl,fill = 'black')
			can.create_line(x,y+scl/2,x,y+scl*4)
	elif ch == '}':
		print "}"
		if down1 == False or down == False:
			can.create_oval(x,y,x+scl,y+scl,fill = 'black')
			can.create_line(x+scl,y+scl/2,x+scl,y-scl*3)
			can.create_line(x2+scl,y2-scl*3,x+scl,y-scl*3,width = 2)
			can.create_line(x2+scl,y2-scl*2.5,x+scl,y-scl*2.5,width = 2)
		else:
			can.create_oval(x,y,x+scl,y+scl,fill = 'black')
			can.create_line(x,y+scl/2,x,y+scl*4)
			can.create_line(x2,y2+scl*4,x,y+scl*4,width = 2)
			can.create_line(x2,y2+scl*4.5,x,y+scl*4.5,width = 2)
	elif ch == "-":
		print "-"
		if down == False:
			if char1 == "F": 
				can.create_oval(x,y,x+scl,y+scl,fill = 'black')
				can.create_line(x+scl,y+scl/2,x+scl,y-scl*3)
			elif char1 == "G": 
				can.create_oval(x,y,x+scl,y+scl,fill = 'black')
				can.create_line(x+scl,y+scl/2,x+scl,y-scl*2.5)
			elif char == "D": 
				can.create_oval(x,y,x+scl,y+scl,fill = 'black')
				can.create_line(x+scl,y+scl/2,x+scl,y-scl*3.3)
			else:		
				can.create_oval(x,y,x+scl,y+scl,fill = 'black')
				can.create_line(x+scl,y+scl/2,x+scl,y-scl*3)
		else:
			if char == "F": 
				can.create_oval(x,y,x+scl,y+scl,fill = 'black')
				can.create_line(x+scl,y+scl/2,x+scl,y-scl*2.7)
			elif char == "D": 
				can.create_oval(x,y,x+scl,y+scl,fill = 'black')
				can.create_line(x+scl,y+scl/2,x+scl,y-scl*3.3)
			elif char1 == "d": 
				can.create_oval(x,y,x+scl,y+scl,fill = 'black')
				can.create_line(x,y+scl/2,x,y+scl*4.5)
			elif char1 == "e": 
				can.create_oval(x,y,x+scl,y+scl,fill = 'black')
				can.create_line(x,y+scl/2,x,y+scl*5)
			else:		
				can.create_oval(x,y,x+scl,y+scl,fill = 'black')
				can.create_line(x,y+scl/2,x,y+scl*4)
	elif ch == '1':
		print "1"
		if down == False:
			can.create_oval(x,y,x+scl,y+scl,fill = 'black')
			can.create_line(x+scl,y+scl/2,x+scl,y-scl*3)
			can.create_line(x+scl,y-scl*3,x+scl+scl/1.5,y-scl*1,x+scl+scl/2.7,y+scl/5,width = 1.5)
		else:
			can.create_oval(x,y,x+scl,y+scl,fill = 'black')
			can.create_line(x,y+scl/2,x,y+scl*4)
			can.create_line(x,y+scl*4,x+scl/1.1,y+scl*2.5,x+scl/1.5,y+scl*1.3,width = 1.5)
	elif ch == '2':
		if down == False:
			print "2"
			can.create_oval(x,y,x+scl,y+scl,fill = 'black')
			can.create_line(x+scl,y+scl/2,x+scl,y-scl*3)
			#can.create_oval(x+scl*1.5,y+scl/5.5,x+scl*1.8,y+scl/1.8,fill = 'black')
		else:
			#print "1"
			can.create_oval(x,y,x+scl,y+scl,fill = 'black')
			can.create_line(x,y+scl/2,x,y+scl*4)
			#can.create_oval(x+scl*1.5,y+scl/5.5,x+scl*1.8,y+scl/1.9,fill = 'black')
	elif ch == '3':
		if down == False:
			print "1"
			can.create_oval(x,y,x+scl,y+scl,fill = 'black')
			can.create_line(x+scl,y+scl/2,x+scl,y-scl*3)
			can.create_oval(x+scl*1.5,y+scl/5.5,x+scl*1.8,y+scl/1.8,fill = 'black')
		else:
			#print "1"
			can.create_oval(x,y,x+scl,y+scl,fill = 'black')
			can.create_line(x,y+scl/2,x,y+scl*4)
			can.create_oval(x+scl*1.5,y+scl/5.5,x+scl*1.8,y+scl/1.9,fill = 'black')
	elif ch == '4':
		if down == False:
			print "4"
			can.create_oval(x,y,x+scl,y+scl)
			can.create_line(x+scl,y+scl/2,x+scl,y-scl*3)
			#can.create_oval(x+scl*1.5,y+scl/5.5,x+scl*1.8,y+scl/1.8,fill = 'black')
		else:
			#print "1"
			can.create_oval(x,y,x+scl,y+scl)
			can.create_line(x,y+scl/2,x,y+scl*4)
			#can.create_oval(x+scl*1.5,y+scl/5.5,x+scl*1.8,y+scl/1.9,fill = 'black')
	elif ch == '6':
		if down == False:
			print "6"
			can.create_oval(x,y,x+scl,y+scl)
			can.create_line(x+scl,y+scl/2,x+scl,y-scl*3)
			can.create_oval(x+scl*1.5,y+scl/5.5,x+scl*1.8,y+scl/1.8,fill = 'black')
		else:
			#print "1"
			can.create_oval(x,y,x+scl,y+scl)
			can.create_line(x,y+scl/2,x,y+scl*4)
			can.create_oval(x+scl*1.5,y+scl/5.5,x+scl*1.8,y+scl/1.9,fill = 'black')
	elif ch == '8':
		if down == False:
			print "8"
			can.create_oval(x,y,x+scl,y+scl)
			#can.create_line(x+scl,y+scl/2,x+scl,y-scl*3)
			#can.create_oval(x+scl*1.5,y+scl/5.5,x+scl*1.8,y+scl/1.8,fill = 'black')
		else:
			#print "1"
			can.create_oval(x,y,x+scl,y+scl)
			#can.create_line(x,y+scl/2,x,y+scl*4)
			#can.create_oval(x+scl*1.5,y+scl/5.5,x+scl*1.8,y+scl/1.9,fill = 'black')
	elif ch == '|':
		print "|"
		can.create_line(pos_x[i]-scl/2,scl*15,pos_x[i]-scl/2,scl*11,width = 1.5)
	elif ch == 'r':
		print "|"
		can.create_line(pos_x[i]-scl/2,scl*15,pos_x[i]-scl,scl*13,width = 1.5)
	elif ch == 'z':
		print "|"
		can.create_line(pos_x[i]-scl/2,scl*15,pos_x[i]-scl/2,scl*13,width = 1.5)
	elif ch == 'x':
		print "|"
		can.create_line(pos_x[i]-scl/2,scl*15,pos_x[i]+scl,scl*13,width = 1.5)
	elif ch == " ":
		pass
		i = i + 1
	else:
		continue
stan()
ff.close()
can.postscript(file = "out.ps",width = '740',height = '780')
root.mainloop()
